package com.mmlc.meimei.lichengkongjian.classify;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ListView;

import com.mmlc.inter.InterFragment;
import com.mmlc.meimei.lichengkongjian.Adapter.ClassifyAdapter;
import com.mmlc.meimei.lichengkongjian.R;
import com.mmlc.network.responsebean.CategoryListResponseBean;
import com.mmlc.utils.ViewUtils;

/**
 * Created by Administrator on 2016/10/14.
 */

public class ClassifyUiFragment extends InterFragment {

    ListView list_classify;

    ClassifyAdapter adapter;

    CategoryListResponseBean result;

    private int index;

    @Override
    protected int initResourceID() {
        return R.layout.fragment_classifyui;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (savedInstanceState != null)
        {
            result = savedInstanceState.getParcelable("data");
            index = savedInstanceState.getInt("index");
        }
        else
        {
            result = getArguments().getParcelable("data");
            index=getArguments().getInt("index");
        }

    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putParcelable("data",result);
        outState.putInt("index",index);
    }

    @Override
    protected void initView() {
        list_classify = ViewUtils.getView(view, R.id.list_classify);
        adapter = new ClassifyAdapter(context, result.getData().get(index).getList(), list_classify);
        list_classify.setAdapter(adapter);
    }
}
